local extension = Package("wdtx")
extension.extensionName = "wdtx"
extension:loadSkillSkelsByPath("./packages/wdtx/pkg/WDTX_token/skills")
extension.game_modes_whitelist = { "wdtx_mode" }

General(extension, "hxfc_author", "wei", 1):addSkills{"#wdtx_modskill"}

local wumingshi = General(extension, "wumingshi", "qun", 5)
Fk:loadTranslationTable {
  ["wumingshi"] = "无名氏",
  ["#wumingshi"] = "未知",
  ["~wumingshi"] = "",
}

local hj_daobing = General:new(extension, "hj_daobing", "qun", 3)
hj_daobing:addSkills { "hj_daofa", "hj_silue", "hj_tiandao" }

local wm_guanyu = General:new(extension, "wm_guanyu", "qun", 4)
wm_guanyu:addSkills { "wm_daowu", "wm_fenzhan", "rende", "damage_maker" }

local wm_zhangfei = General:new(extension, "wm_zhangfei", "qun", 4)
wm_zhangfei:addSkills { "wm_xiongmeng", "wm_fenzhan" }

local hj_gongshou = General:new(extension, "hj_gongshou", "qun", 4)
hj_gongshou:addSkills {
  "hj_gongshi",
  "hj_tiandao"
}
  -- "hj_qingzhuang",

local hj_daoqibing = General:new(extension, "hj_daoqibing", "qun", 4)
hj_daoqibing:addSkills { "hj_lieqi", "hj_daofa", "hj_tiandao" }

local shanzei_boss = General:new(extension, "shanzei_boss", "qun", 7)
shanzei_boss:addSkills { "sz_shouling" }

local shanzei_loulou = General:new(extension, "shanzei_loulou", "qun", 3)
shanzei_loulou:addSkills { "hj_silue" }

Fk:loadTranslationTable {
  ["wumingshi"] = "无名氏",
  ["#wumingshi"] = "未知",
  ["~wumingshi"] = "",
  ["hj_daobing"] = "黄巾刀兵",
  ["hj_daofa"] = "刀法",
  [":hj_daofa"] = "锁定技，出牌阶段你使用杀次数+1",
  ["hj_silue"] = "肆掠",
  [":hj_silue"] = "锁定技，每回合限一次，你对一名其他角色造成伤害后，你可以获得其1张牌",
  ["hj_tiandao"] = "天道",
  [":hj_tiandao"] = "锁定技，你的回合开始时，你进行一次判定，若判定牌为红色你可以弃1张红色手牌回复1点体力否则获得此判定牌然后失去1点体力",
  ["wm_guanyu"] = "关羽",
  ["wm_daowu"] = "刀武",
  ["#wm_daowu-choose"] = "刀武：你可以为%arg增加至多%arg2个目标",
  [":wm_daowu"] = "锁定技，每轮开始，把专属武器【青龙偃月刀】置入武器栏。你使用杀被抵消，本回合内你的下一张杀指向目标+1",
  ["wm_fenzhan"] = "奋战",
  ["@@fenzhan_slash-phase"] = "奋战",
  ["#wm_fenzhan_mod"] = "奋战",
  [":wm_fenzhan"] = "锁定技，出牌阶段开始，你从牌堆获得一张不计入次数的杀。若使用此杀被抵消随机丢弃自己1张牌，否则弃其1张牌。此杀造成死亡，从牌堆获得伤害锦囊牌，非伤害基本牌，装备牌各一张。",
  ["wm_zhangfei"] = "张飞",
  ["wm_xiongmeng"] = "雄猛",
  [":wm_xiongmeng"] = "锁定技，你于回合内使用第一张杀指向目标无法被响应，使用除第一张的杀指向目标伤害+1",
  ["#story_savegz_skill"] = "",
  ["hj_gongshou"] = "黄巾弓手",
  ["hj_gongshi"] = "灵矢",
  [":hj_gongshi"] = "锁定技，你的攻击范围+5。你使用杀指向目标时。有50%概率伤害+1",
  ["hj_qingzhuang"] = "轻装",
  [":hj_qingzhuang"] = "锁定技，出牌阶段开始时若你有装备牌，弃掉所有装备牌然后检索牌堆x张非装备牌（x为弃掉装备牌数*1.5向上取整）",
  ["hj_daoqibing"] = "黄巾骑兵",
  ["#hj_lieqi_dis"] = "烈骑",
  ["hj_lieqi"] = "烈骑",
  [":hj_lieqi"] = "锁定技，你与其他角色的距离-1。你使用【杀】指向距离为1的目标时不可被响应。出牌阶段开始时若你有锦囊牌，弃掉所有锦囊牌然后检索牌堆x张非锦囊牌（x为弃掉锦囊牌数*1.5向上取整）",
  ["shanzei_boss"] = "山贼首领",
  ["shanzei_loulou"] = "山贼",
  ["@morale"] = "士气+",
  ["#moralMaxMod"] = "士气",
  ["#moralTargetmod"] = "士气",
  ["sz_shouling"] = "首领",
  [":sz_shouling"] = "锁定技，你的回合开始，复活一名山贼。所有山贼获得1层“士气”标记。每当角色有1层此标记。手牌上限+1，2层回合内使用【杀】次数+1，3层摸牌阶段多摸1张，4层使用【杀】造成伤害+1。",
}



--[[
--黄巾刀兵
local hj_daobing = General(extension, "hj_daobing", "qun", 3)
local hj_daofa = fk.CreateTargetModSkill{
  name = "hj_daofa",
  residue_func = function(self, player, skill, scope)
    if player:hasSkill(self) and skill.trueName == "slash_skill" then
      return 1
    end
  end,
}
local hj_silue = fk.CreateTriggerSkill{
  name = "hj_silue",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.Damage},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and
      data.to ~= player and not data.to.dead and not data.to:isNude()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askForCardChosen(player, data.to, "he", self.name)
    if cards then
      room:obtainCard(player, cards, true, fk.ReasonPrey, player, self.name)
    end
  end,
}
local hj_tiandao = fk.CreateTriggerSkill{
  name = "hj_tiandao",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.TurnStart},
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and player == target
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local judge = {
      who = player,
      reason = self.name,
    }
    room:judge(judge)
    if not judge.card then return end
    if judge.card.color == Card.Red then
      if #player.player_cards[Player.Hand] == 0 or not player:isWounded() then return end
      local cids = room:askForDiscard(player,1,1,false,self.name,true,".|.|".."heat,diamond".."|.|.|.")
      if cids and #cids > 0 then
        room:recover({
          who = player,
          num = 1,
          recoverBy = player,
          skillName = self.name
        })
      end
    else
      room:obtainCard(player, judge.card, true, fk.ReasonJustMove, player, self.name)
      room:loseHp(player,1,self.name)
    end
  end,
}
hj_daobing:addSkill(hj_daofa)
hj_daobing:addSkill(hj_silue)
hj_daobing:addSkill(hj_tiandao)
Fk:loadTranslationTable{
  ["hj_daobing"] = "黄巾刀兵",
  ["hj_daofa"] = "刀法",
  [":hj_daofa"] = "锁定技，出牌阶段你使用杀次数+1",
  ["hj_silue"] = "肆掠",
  [":hj_silue"] = "锁定技，每回合限一次，你对一名其他角色造成伤害后，你可以获得其1张牌",
  ["hj_tiandao"] = "天道",
  [":hj_tiandao"] = "锁定技，你的回合开始时，你进行一次判定，若判定牌为红色你可以弃1张红色手牌回复1点体力否则获得此判定牌然后失去1点体力",

}

local putEquipHandle = function (who,type,id,proposer,skiname)
  local room = who.room
  local eid = who:getEquipment(type)
  room:moveCards({
    from = who,
    ids = {id},
    toArea = Card.Processing,
    moveReason = fk.ReasonJustMove,
    proposer = who,
    skillName = skiname,
})
  local move3 = {
    ids = {id},
    fromArea = Card.Processing,
    to = who,
    toArea = Card.PlayerEquip,
    moveReason = fk.ReasonJustMove,
    proposer = proposer or who,
    skillName = skiname,
  }

  if eid ~= nil then
    local move2 = {
      ids = {eid},
      from = who,
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonJustMove,
    }
    room:moveCards(move2, move3)
  else
    room:moveCards(move3)
  end
end

local wm_guanyu = General(extension, "wm_guanyu", "qun", 4)
local wm_daowu = fk.CreateTriggerSkill{
  name = "wm_daowu",
  priority = 10,
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.RoundStart,fk.CardEffectCancelledOut,fk.TargetSpecifying,fk.TurnEnd},
  can_trigger = function (self, event, target, player, data)
    if not player:hasSkill(self) then return end
    if event == fk.RoundStart then
      return not player:getEquipment(Card.SubtypeWeapon) or Fk:getCardById(player:getEquipment(Card.SubtypeWeapon)).name ~= "blade"
    elseif event == fk.CardEffectCancelledOut then
      return data.from == player and data.card.trueName == "slash"
    elseif event == fk.TargetSpecifying then
      return target == player and not player.dead and data.card.trueName == "slash" and player:getMark("daowu_extra-turn") > 0 and #U.getUseExtraTargets(player.room, data) > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.RoundStart then
      local totalcards = room.totalcards or Fk:getAllCardIds()
      for _, id in ipairs(totalcards) do
        local card = Fk:getCardById(id, true)
        if card.name == "blade" then
          local area = room:getCardArea(card.id)
          if area == Player.Hand or area == Player.Equip or area == Player.Special then
            room:obtainCard(player,id,true,fk.ReasonJustMove)
            putEquipHandle(player,Card.SubtypeWeapon,id,player,self.name)
          else
            putEquipHandle(player,Card.SubtypeWeapon,id,player,self.name)
          end
          break
        end
      end
    elseif event == fk.CardEffectCancelledOut then
      room:addPlayerMark(player,"daowu_extra-turn",1)
    elseif event == fk.TargetSpecifying then
      local targets = U.getUseExtraTargets(room, data)
      if #targets == 0 then return false end
      local tars = player:getMark("daowu_extra-turn")
      local tos = room:askForChoosePlayers(player, targets, 1, tars, "#wm_daowu-choose:::"..data.card:toLogString()..":"..tars, self.name, true)
      if #tos > 0 then
        table.forEach(tos, function (id)
          TargetGroup:pushTargets(data.targetGroup, id)
        end)
      end
    end
  end,
}
local wm_fenzhan = fk.CreateTriggerSkill{
  name = "wm_fenzhan",
--   anim_type = "control",
  priority = 9,
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart,fk.DamageInflicted,fk.CardEffectCancelledOut,fk.Death},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return end
    if event == fk.EventPhaseStart then
      return target == player and player.phase == Player.Play
    elseif event == fk.DamageInflicted then
      return data.from and data.from == player and not data.to:isNude() and data.card and data.card:getMark("@@fenzhan_slash-phase") == 1
    elseif event == fk.CardEffectCancelledOut then
      return data.from and data.from == player and data.card.trueName == "slash" and not player:isNude() and data.card:getMark("@@fenzhan_slash-phase") == 1
    elseif event == fk.Death then
      return target ~= player and data.damage and data.damage.from and data.damage.from == player and data.damage.card and data.damage.card:getMark("@@fenzhan_slash-phase") == 1
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      local slash
      local needname,cardmark = "slash","@@fenzhan_slash-phase"
      for _, cid in ipairs(room.draw_pile) do
        local card = Fk:getCardById(cid)
        if card.trueName == needname then slash = card break end
      end
      if not slash then
        for _, cid in ipairs(room.discard_pile) do
          local card = Fk:getCardById(cid)
          if card.trueName == needname then slash = card break end
        end
      end
      if slash then
        room:setCardMark(slash,cardmark,1)
        room:obtainCard(player, slash, true, fk.ReasonJustMove)
      end
    elseif event == fk.DamageInflicted then
      local cards = room:askForCardChosen(player, data.to, "he", self.name)
      if cards then
        room:throwCard(cards, self.name, data.to, player)
      end
    elseif event == fk.CardEffectCancelledOut then
      local cards = player:getCardIds("he")
      local throwid = table.random(cards)
      room:throwCard(throwid, self.name, player, player)
    elseif event == fk.Death then
      local getcards = {0,0,0}
      for _, cid in ipairs(room.draw_pile) do
        local card = Fk:getCardById(cid)
        if getcards[1] == 0 and card.type == Card.TypeBasic and not card.is_damage_card then getcards[1] = cid end
        if getcards[2] == 0 and card.type == Card.TypeTrick and card.is_damage_card then getcards[2] = cid end
        if getcards[3] == 0 and card.type == Card.TypeEquip then getcards[3] = cid end
      end
      if getcards[1] == 0 or getcards[2] == 0 or getcards[3] == 0 then
        for _, cid in ipairs(room.discard_pile) do
          local card = Fk:getCardById(cid)
          if getcards[1] == 0 and card.type == Card.TypeBasic and not card.is_damage_card then getcards[1] = cid end
          if getcards[2] == 0 and card.type == Card.TypeTrick and card.is_damage_card then getcards[2] = cid end
          if getcards[3] == 0 and card.type == Card.TypeEquip then getcards[3] = cid end
        end
      end
      if #getcards > 0 then
        room:obtainCard(player, getcards, true, fk.ReasonJustMove)
      end
    end
  end,
}
local wm_fenzhan_mod = fk.CreateTargetModSkill{
  name = "#wm_fenzhan_mod",
  bypass_times = function(self, player, skill, scope, card, to)
    return player:hasSkill(wm_fenzhan) and card:getMark("@@fenzhan_slash-phase") == 1
  end
}
wm_fenzhan:addRelatedSkill(wm_fenzhan_mod)
wm_guanyu:addSkill(wm_daowu)
wm_guanyu:addSkill(wm_fenzhan)
-- wm_guanyu:addSkill("rende")
-- wm_guanyu:addSkill("damage_maker")
Fk:loadTranslationTable{
  ["wm_guanyu"] = "关羽",
  ["wm_daowu"] = "刀武",
  ["#wm_daowu-choose"] = "刀武：你可以为%arg增加至多%arg2个目标",
  [":wm_daowu"] = "锁定技，每轮开始，把专属武器【青龙偃月刀】置入武器栏。你使用杀被抵消，本回合内你的下一张杀指向目标+1",
  ["wm_fenzhan"] = "奋战",
  ["@@fenzhan_slash-phase"] = "奋战",
  ["#wm_fenzhan_mod"] = "奋战",
  [":wm_fenzhan"] = "锁定技，出牌阶段开始，你从牌堆获得一张不计入次数的杀。若使用此杀被抵消随机丢弃自己1张牌，否则弃其1张牌。此杀造成死亡，从牌堆获得伤害锦囊牌，非伤害基本牌，装备牌各一张。",
}

local wm_zhangfei = General(extension, "wm_zhangfei", "qun", 4)
local wm_xiongmeng = fk.CreateTriggerSkill{
  name = "wm_xiongmeng",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and target == player and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    -- data.additionalEffect = (data.additionalEffect or 0) + 1
    if player:usedCardTimes("slash",Player.HistoryPhase) == 1 then
      data.disresponsive = true
    else
      data.additionalDamage = (data.additionalDamage or 0) + 1
    end
  end,
}
wm_zhangfei:addSkill(wm_xiongmeng)
wm_zhangfei:addSkill("wm_fenzhan")
Fk:loadTranslationTable{
  ["wm_zhangfei"] = "张飞",
  ["wm_xiongmeng"] = "雄猛",
  [":wm_xiongmeng"] = "锁定技，你于回合内使用第一张杀指向目标无法被响应，使用除第一张的杀指向目标伤害+1",
}

local story_savegz_skill = fk.CreateTriggerSkill{
  name = "#story_savegz_skill",
  -- anim_type = "drawcard",
  frequency = Skill.Compulsory,
  -- visible = false,
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.room.logic.Wdtx
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local Wdtx = room.logic.Wdtx
    for i, pr in ipairs(room.players) do
      if pr:hasSkill(self) then
        room:handleAddLoseSkills(pr, "-"..self.name, nil, false)
      end
    end
    room:setTag("savegz",player.id)
    local curinfo = Wdtx.storyobj:getCurInfo()
    Wdtx.storyobj:setCurInfo({startpos = curinfo.startpos,selchcinx = 1})
    Wdtx:continueStory(curinfo.startpos,1)
  end
}
Fk:addSkill(story_savegz_skill)
Fk:loadTranslationTable{
  ["#story_savegz_skill"] = "",
}

local hj_gongshou = General(extension, "hj_gongshou", "qun", 4)
local hj_gongshi = fk.CreateTriggerSkill{
  name = "hj_gongshi",
  anim_type = "support",
  priority = 2,
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and not player.dead and data.card.trueName == "slash" and player == target and math.random() < 0.5
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.additionalDamage = (data.additionalDamage or 0) + 1
    -- local targets = U.getUseExtraTargets(room, data)
    -- if #targets == 0 then return false end
    -- local tars = #table.filter(player.player_cards[Player.Hand],function(cid) return Fk:getCardById(cid).trueName == "slash" end)
    -- local tos = room:askForChoosePlayers(player, targets, 1, tars, nil, self.name, true)
    -- if #tos > 0 then
    --   table.forEach(tos, function (id)
    --     TargetGroup:pushTargets(data.targetGroup, id)
    --   end)
    -- end
  end,
}
local gongshi_atkrange = fk.CreateAttackRangeSkill {
  name = "#gongshi_atkrange",
  frequency = Skill.Compulsory,
  correct_func = function(self, from, to)
    if from:hasSkill(hj_gongshi) then
      return 5
    end
  end,
}
hj_gongshi:addRelatedSkill(gongshi_atkrange)

-- local hj_qingzhuang = fk.CreateTriggerSkill{
--   name = "hj_qingzhuang",
--   anim_type = "support",
--   frequency = Skill.Compulsory,
--   events = {fk.EventPhaseStart},
--   can_trigger = function(self, event, target, player, data)
--     return player:hasSkill(self) and target == player and player.phase == Player.Play and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and table.find(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeEquip end)
--   end,
--   on_use = function(self, event, target, player, data)
--     local room = player.room
--     local equips = table.filter(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeEquip end)
--     local discs = math.ceil(#equips * 1.5)
--     room:throwCard(equips, self.name, player, player)
--     WU:checkCards(player,".|.|.|.|.|^equip",discs)
--   end,
-- }
hj_gongshou:addSkill(hj_gongshi)
-- hj_gongshou:addSkill(hj_qingzhuang)
hj_gongshou:addSkill("hj_tiandao")
Fk:loadTranslationTable{
  ["hj_gongshou"] = "黄巾弓手",
  ["hj_gongshi"] = "灵矢",
  [":hj_gongshi"] = "锁定技，你的攻击范围+5。你使用杀指向目标时。有50%概率伤害+1",
  -- ["hj_qingzhuang"] = "轻装",
  -- [":hj_qingzhuang"] = "锁定技，出牌阶段开始时若你有装备牌，弃掉所有装备牌然后检索牌堆x张非装备牌（x为弃掉装备牌数*1.5向上取整）",
}

local hj_daoqibing = General(extension, "hj_daoqibing", "qun", 4)
local hj_lieqi = fk.CreateTriggerSkill{
  name = "hj_lieqi",
  anim_type = "support",
  frequency = Skill.Compulsory,
  events = {fk.EventPhaseStart,fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) or target ~= player then return end
    if event == fk.EventPhaseStart then
      return player.phase == Player.Play and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and table.find(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeTrick end)
    else
      return data.card.trueName == "slash" and player:distanceTo(player.room:getPlayerById(data.to)) == 1
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.EventPhaseStart then
      local tricks = table.filter(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeTrick end)
      local discs = math.ceil(#tricks * 1.5)
      room:throwCard(tricks, self.name, player, player)
      WU:checkCards(player,".|.|.|.|.|^trick",discs)
    else
      data.disresponsive = true
    end
  end,
}
local hj_lieqi_dis = fk.CreateDistanceSkill{
  name = "#hj_lieqi_dis",
  correct_func = function(self, from, to)
    if from:hasSkill(hj_lieqi) then
      return -1
    end
  end,
}
hj_lieqi:addRelatedSkill(hj_lieqi_dis)
hj_daoqibing:addSkill(hj_lieqi)
-- hj_daoqibing:addSkill("hj_daofa")
hj_daoqibing:addSkill("hj_tiandao")
Fk:loadTranslationTable{
  ["hj_daoqibing"] = "黄巾骑兵",
  ["#hj_lieqi_dis"] = "烈骑",
  ["hj_lieqi"] = "烈骑",
  [":hj_lieqi"] = "锁定技，你与其他角色的距离-1。你使用【杀】指向距离为1的目标时不可被响应。出牌阶段开始时若你有锦囊牌，弃掉所有锦囊牌然后检索牌堆x张非锦囊牌（x为弃掉锦囊牌数*1.5向上取整）",
}

local shanzei_boss = General(extension, "shanzei_boss", "qun", 7)
local shanzei_loulou = General(extension, "shanzei_loulou", "qun", 3)
local sz_shouling = fk.CreateTriggerSkill{
  name = "sz_shouling",
  anim_type = "support",
  priority = 3,
  frequency = Skill.Compulsory,
  events = {fk.TurnStart,fk.DrawNCards,fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    if event == fk.TurnStart then
      return player:hasSkill(self) and target == player
    elseif event == fk.DrawNCards then
      return player:getMark("@morale") > 2 and target == player
    else
      return player:getMark("@morale") > 3 and not player.dead and data.from and data.from == player and data.card and data.card.trueName == "slash"
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.TurnStart then
      for _,pr in ipairs(room.alive_players) do
        if string.startsWith(pr.general,"shanzei") then
          room:addPlayerMark(pr,"@morale")
        end
      end
      local others = room:getOtherPlayers(player,false,true)
      if #others == 0 then return end
      local deadplayer = table.find(others,function(pr) return pr.dead end)
      if deadplayer then
        room:changeHero(deadplayer, "shanzei_loulou", true, false, true)
        room:revivePlayer(deadplayer, false)
        room:askForChooseKingdom({deadplayer})
        -- if deadplayer.role ~= "rebel" then
        --   room:setPlayerProperty(deadplayer, "role", "rebel")
        -- end
        room:drawCards(deadplayer, 4,self.name)
      end
    elseif event == fk.DrawNCards then
      data.n = data.n + 1
    else
      data.damage = data.damage + 1
    end
  end,
}
local moralMaxMod = fk.CreateMaxCardsSkill{
  name = "#moralMaxMod",
  frequency = Skill.Compulsory,
  correct_func = function (self, player)
    if player:getMark("@morale") > 0 then
      return 1
    end
  end,
}
local moralTargetmod = fk.CreateTargetModSkill{
  name = "#moralTargetmod",
  frequency = Skill.Compulsory,
  residue_func = function(self, player, skill, scope)
    if player:getMark("@morale") > 1 and skill.trueName == "slash_skill" then
      return 1
    end
  end,
}
sz_shouling:addRelatedSkill(moralMaxMod)
sz_shouling:addRelatedSkill(moralTargetmod)
shanzei_boss:addSkill(sz_shouling)
shanzei_loulou:addSkill("hj_silue")
Fk:loadTranslationTable{
  ["shanzei_boss"] = "山贼首领",
  ["shanzei_loulou"] = "山贼",
  ["@morale"] = "士气+",
  ["#moralMaxMod"] = "士气",
  ["#moralTargetmod"] = "士气",
  ["sz_shouling"] = "首领",
  [":sz_shouling"] = "锁定技，你的回合开始，复活一名山贼。所有山贼获得1层“士气”标记。每当角色有1层此标记。手牌上限+1，2层回合内使用【杀】次数+1，3层摸牌阶段多摸1张，4层使用【杀】造成伤害+1。",
}
--]]

return extension
